home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / ae.lha / ae / AEC / adtr.c next >
C/C++ Source or Header  |  1990-02-28  |  2KB  |  91 lines

  1. /* Driver routine to print the results from AE address trace to stdout.
  2.    Copyright (C) 1989, 1990 by James R. Larus (larus@cs.wisc.edu)
  3.  
  4.    AE and AEC are free software; you can redistribute it and/or modify it
  5.    under the terms of the GNU General Public License as published by the
  6.    Free Software Foundation; either version 1, or (at your option) any
  7.    later version.
  8.  
  9.    AE and AEC are distributed in the hope that it will be useful, but
  10.    WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.    General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with GNU CC; see the file COPYING.  If not, write to James R.
  16.    Larus, Computer Sciences Department, University of Wisconsin--Madison,
  17.    1210 West Dayton Street, Madison, WI 53706, USA or to the Free
  18.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  19.  
  20. /* $Header: /var/home/larus/AE/AEC/RCS/adtr.c,v 2.0 90/02/09 17:23:35 larus Exp Locker: larus $ */
  21.  
  22.  
  23. #include <stdio.h>
  24. #include "aec.h"
  25.  
  26.  
  27. void reference ();
  28.  
  29. static int no_output = 0;    /* Print references? */
  30. static int loop_info = 0;    /* Print loop info? */
  31.  
  32. static int num_inst = 0;
  33. static int num_ref = 0;
  34.  
  35.  
  36. main (argc, argv)
  37.      int argc;
  38.      char *argv[];
  39. {
  40.   no_output = (argc > 2);
  41.   if (argc > 2 && *argv[2] == 'l')
  42.     loop_info = 1, no_output = 0;
  43.  
  44.   ae_recreate (argv[1], reference);
  45.   fprintf (stderr, "%d instructions, %d memory references = %d\n", num_inst,
  46.        num_ref, num_inst + num_ref);
  47. }
  48.  
  49.  
  50. void
  51. reference (type, addr, n_inst)
  52.      int type;
  53.      int addr;
  54.      int n_inst;
  55. {
  56.   switch (type)
  57.     {
  58.     case INST_REF:
  59.       num_inst += n_inst;
  60.       if (!no_output) printf ("I x %d: %x\n", n_inst, addr);
  61.       break;
  62.  
  63.     case MEM_READ:
  64.       num_ref ++;
  65.       if (!no_output) printf ("R: %x\n", addr);
  66.       break;
  67.  
  68.     case MEM_WRITE:
  69.       num_ref ++;
  70.       if (!no_output) printf ("W: %x\n", addr);
  71.       break;
  72.  
  73.     case START_LOOP:
  74.       if (!no_output && loop_info) printf("SL: %d\n", addr);
  75.       break;
  76.  
  77.     case CONT_LOOP:
  78.       if (!no_output && loop_info) printf("CL: %d\n", addr);
  79.       break;
  80.  
  81.     case END_LOOP:
  82.       if (!no_output && loop_info) printf("EL: %d\n", addr);
  83.       break;
  84.  
  85.     default:
  86.       if (!no_output) printf ("?: %x\n", addr);
  87.       break;
  88.     }
  89. }
  90.  
  91.